<?php
class users extends Controller{

	var $models = array('User');
	
	function index(){
		$d = array();
		if (isset($_SESSION['User']['id']) && !empty($_SESSION['User']['id'])){
			$d['users'] = $this->User->findFirst(array(
				'conditions' => 'id='.$_SESSION['User']['id'],
				'order' => 'id DESC'
			));
			$this->loadModel('Cour');
			$d['cours'] = $this->Cour->find(array(
				'conditions' => 'user='.$_SESSION['User']['id'],
			));
		}
		else{
			echo 'Pb de connexion';
		}
		$this->layout = 'user';
		$this->set($d);
		$this->render('index');
	}
	
	function inscription (){
		$d = array();
		$this->loadModel('Classe');
		$d['classes'] =$this->Classe->find(array(
				"order" => "libelle"
		));
		$this->set($d);
		$this->render('inscription');
	}

	function deconnexion(){
		$this->Session->logout();
		$this->redirect();
	}
}